home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
tcqbsnip.zip
/
GETARY.BAS
< prev
next >
Wrap
BASIC Source File
|
1997-06-20
|
878b
|
28 lines
' GETARY.BAS
' by Tika Carr
'
' Donated to the public domain
' No warranties or guarantees are expressed or implied.
'
' Purpose: Calculates maximum array size for GET/PUT
DECLARE FUNCTION GetAry! (x1%, y1%, x2%, y2%, mode%)
DEFINT A-Z
'This would set up enough space to hold a sprite that's taken from:
'Upper left: 100, 100 Lower right: 145, 130
'Any errors may be due to the fact the array is too large to hold.
'try using '$DYNAMIC and loading qb with the /ah switch.
'REDIM Buffer(1 TO GetAry!(100, 100, 145, 130, 13))
FUNCTION GetAry! (x1%, y1%, x2%, y2%, mode%)
IF mode% = 1 THEN bpp = 2: pln = 1
IF mode% = 2 OR mode% = 11 THEN bpp = 1: pln = 1
IF (mode% > 6 AND mode% < 10) OR mode% = 12 THEN bpp = 1: pln = 4
IF mode% = 13 THEN bpp = 8: pln = 1
GetAry = 4 + INT(((x2% - x1% + 1) * bpp + 7) / 8) * pln * ((y2% - y1%) + 1)
END FUNCTION